<!DOCTYPE html>
<html lang="zh-cn">
   <head>
      <meta charset="utf-8">
      <meta http-equiv="X-UA-Compatible" content="IE=edge">
      <meta name="viewport" content="width=device-width, initial-scale=1">
      <title>{$CONF['mallTitle']}后台管理中心</title>
      <link href="__PUBLIC__/plugins/bootstrap/css/bootstrap.min.css" rel="stylesheet">
      <link href="__CSS__/AdminLTE.css" rel="stylesheet" type="text/css" />
      <!--[if lt IE 9]>
      <script src="__PUBLIC__/js/html5shiv.min.js"></script>
      <script src="__PUBLIC__/js/respond.min.js"></script>
      <![endif]-->
      <script src="__PUBLIC__/js/jquery.min.js"></script>
      <script src="__PUBLIC__/plugins/bootstrap/js/bootstrap.min.js"></script>
      <script src="__PUBLIC__/js/common.js"></script>
      <script src="__PUBLIC__/plugins/plugins/plugins.js"></script>
      <script src="__PUBLIC__/plugins/kindeditor/kindeditor.js"></script>
      <script src="__PUBLIC__/plugins/kindeditor/lang/zh_CN.js"></script>

       <!--时间日历插件-->
       <script type="text/javascript" src="__PUBLIC__/plugins/jeDate/jedate.js"></script>
       <script src="__PUBLIC__/plugins/layer/layer.min.js"></script>
       <style>
           .datainp{ width:150px; }
           ul,li,dl,dd,dt{
               list-style-type: none;
           }
       </style>
   </head>
   <style>
    .wst-tab-box{width:100%; height:auto; margin:0px auto;}
	.wst-tab-nav{margin:0; padding:0; height:25px; line-height:24px;position: relative;top:2px;left:3px;}
	.wst-tab-nav li{cursor:pointer;float:left; margin:0 0px; list-style:none; border:1px solid #ddd; border-bottom:none; height:24px; width:100px; text-align:center; background:#eeeeee;color:#000000;}
	.wst-tab-nav .on{background:#ffffff;color:#000000;border-bottom:0 none;}
	.wst-tab-content{padding:5px;width:99%; height:auto; border:1px solid #ddd;background:#FFF;}
    .wst-gallery-imgs{width:770px;height:auto;}
    .wst-gallery-img{width:140px;height:100px;float:left;overflow:hidden;margin:10px 5px 5px 5px;}
   </style>
   <script>
   $(function () {
	   $('#tab').TabPanel({tab:0});
	   KindEditor.ready(function(K) {
			editor1 = K.create('textarea[name="goodsDesc"]', {
				height:'250px',
				allowFileManager : false,
				allowImageUpload : true,
				items:[
				        'source', '|', 'undo', 'redo', '|', 'preview', 'print', 'template', 'code', 'cut', 'copy', 'paste',
				        'plainpaste', 'wordpaste', '|', 'justifyleft', 'justifycenter', 'justifyright',
				        'justifyfull', 'insertorderedlist', 'insertunorderedlist', 'indent', 'outdent', 'subscript',
				        'superscript', 'clearhtml', 'quickformat', 'selectall', '|', 'fullscreen', '/',
				        'formatblock', 'fontname', 'fontsize', '|', 'forecolor', 'hilitecolor', 'bold',
				        'italic', 'underline', 'strikethrough', 'lineheight', 'removeformat', '|','image','table', 'hr', 'emoticons', 'baidumap', 'pagebreak',
				        'anchor', 'link', 'unlink', '|', 'about'
				],
				afterBlur: function(){ this.sync(); }
			});
		});
   });
   
   
   function changeStatus(id,v){
	   Plugins.waitTips({title:'信息提示',content:'正在操作，请稍后...'});
	   $.post("{:U('Admin/Seckill/changeGoodsStatus')}",{id:id,status:v},function(data,textStatus){
				var json = WST.toJson(data);console.log(json);
				if(json.status=='1'){
					Plugins.setWaitTipsMsg({ content:'操作成功',timeout:1000,callback:function(){
						location.href="{:U('Admin/Seckill/index')}";
					}});
				}else{
					Plugins.closeWindow();
					Plugins.Tips({title:'信息提示',icon:'error',content:'操作失败!',timeout:1000});
				
				}
	   });
   }
   function getState(){
	   var val=$('input:radio[name="stateRadio"]:checked').val();
	   return val;
   }
   function getStartTime(){
       return $('#startTime').val();
   }
   function getEndTime(){
       return $('#endTime').val();
   }
   function updateTime(id,v,start,end){

	   Plugins.waitTips({title:'信息提示',content:'正在操作，请稍后...'});
	   $.post("{:U('Admin/Seckill/changePenddingGoodsStatus')}",{id:id,status:v,seckillStartTime:start,seckillEndTime:end},function(data,textStatus){
		   var json = WST.toJson(data);
		   if(json.status=='1'){
			   Plugins.setWaitTipsMsg({ content:'修改成功',timeout:1000,callback:function(){
				   location.href="{:U('Admin/Seckill/index')}";
			   }});
		   }else if(json.status=='2'){
               Plugins.closeWindow();
               Plugins.Tips({title:'信息提示',icon:'error',content:'结束时间不得小于开始时间!',timeout:1000});
           }else{
               Plugins.closeWindow();
               Plugins.Tips({title:'信息提示',icon:'error',content:'操作失败!',timeout:1000});
           }
	   });
   }
   </script>
   <body class="wst-page">
       <form name="myform" method="post" id="myform">
       <div id='tab' class="wst-tab-box">
		<ul class="wst-tab-nav">
	    	<li>商品信息</li>
	    	<li>商品属性</li>
	        <li>商品相册</li>
	    </ul>
    	<div class="wst-tab-content" style='width:98%;'>
    	<div class='wst-tab-item'>
	        <form name="myform" method="post" id="myform">
	        <input type='hidden' id='id' value='{$object.goodsId}'/>
	        <input type='hidden' id='shopId' value='{$object.shopId}'/>
	        <table class="table table-hover table-striped table-bordered wst-form">
	           <tr>
	             <th width='120'>商品编号：</th>
	             <td width='300'>
	             {$object.goodsSn}
	             </td>
	             </td>
	             <td rowspan='7' style='padding:5px;'>
	             <img id='goodsImgPreview' src='<if condition="$object['goodsImg'] =='' ">__ROOT__/Apps/Home/View/default/img/store_default_sign.png<else/>__ROOT__/{$object['goodsImg']}</if>' width='280' height='280'/><br/>
	             </td>
	           </tr>
	           <tr>
	             <th width='120'>商品名称<font color='red'>*</font>：</th>
	             <td>{$object.goodsName}</td>
	           </tr>
	            <tr>
	             <th width='120'>店铺价格<font color='red'>*</font>：</th>
	             <td>{$object.shopPrice}</td>
	           </tr>
	           <tr>
	             <th width='120'>秒杀价格<font color='red'>*</font>：</th>
	             <td>{$object.seckillPrice}</td>
	           </tr>
            <tr>
              <th width='120'>开始日期<font color='red'>*</font>：</th>
                        <td>{$object.seckillStartTime} </td>
            </tr>
            <tr>
              <th width='120'>结束日期<font color='red'>*</font>：</th>
                        <td>{$object.seckillEndTime}</td>
            </tr>
            <tr>
              <th width='120'>开始抢购<font color='red'>*</font>：</th>
                        <td>
                           <if condition="$object['seckillSetTime'] eq 1">
                            8:00
                            <elseif condition="$object['seckillSetTime'] eq 2" />
                            12:00
                            <elseif condition="$object['seckillSetTime'] eq 3" />
                            16:00
                            <elseif condition="$object['seckillSetTime'] eq 4" />
                            20:00
                            <else />
                              00:00
                            </if>
                        </td>
            </tr>
	           <tr>
	             <th width='120'>活动说明<font color='red'>*</font>：</th>
	             <td colspan='3'>{$object.seckillDesc|htmlspecialchars_decode}</td>
	           </tr>
	           <tr>
	             <td colspan='3' style='padding-left:250px;'>
	                 <button type="button" class="btn btn-danger" onclick='javascript:changeStatus({$object['id']},0)'>禁&nbsp;售</button>
	                 <button type="button" class="btn btn-primary" onclick='javascript:location.href="{$referer}"'>返&nbsp;回</button>
	             </td>
	           </tr>
	        </table>
	       </form>
	      </div>
	      <div class='wst-tab-item'>
	        <table class="table table-hover table-striped table-bordered wst-form">
	           <tr>
	             <th width='120'>商品分类：</th>
	             <td>{$object.attrCatName}&nbsp;</td>
	           </tr>
	           <tr>
	             <th width='120'>价格属性：</th>
	             <td style='margin:0px;'>
	             <if condition=" count($object.priceAttrs) gt 0">
					<table class="table wst-list" style='margin:0px;border-top:1px solid #ddd;'>
					<thead>
					<tr>
					  <th style='background:#f5f5f5'>属性</th>
					  <th style='background:#f5f5f5'>规格</th>
					  <th style='background:#f5f5f5'>价格</th>
					  <th style='background:#f5f5f5'>推荐</th>
					  <th style='background:#f5f5f5'>库存</th>
					</tr>
					</thead>
					<volist name="object.priceAttrs" id="vo">
					<tr style='margin:0px;'>
						<td nowrap width='100px'>{$vo.attrName}</td>
						<td>{$vo['attrVal']}</td>
						<td>{$vo['attrPrice']}</td>
						<td><if condition="$vo.isRecomm eq 1">是</if></td>
						<td>{$vo['attrStock']}</td>
					</tr>
					</volist>
					</table>
				 </if>
	             </td>
	           </tr>
	           <tr>
	             <th width='120' valign='top'>展示属性：</th>
	             <td style='margin:0px;'>
	             <if condition=" count($object.attrs) gt 0">
					<table class="table  wst-form" style='margin:0px;'>
					<volist name="object.attrs" id="vo">
					<if condition="$vo['attrContent'] !='' ">
					<tr style='margin:0px;border:0px;'>
						<th nowrap width='100px'>{$vo['attrName']}：</th>
						<td>{$vo['attrContent']}</td>
					</tr>
					</if>
					</volist>
					</table>
				 </if>
	             </td>
	           </tr>
	        </table>
	      </div>
	      <div class='wst-tab-item'>
	       <div id='galleryImgs' class='wst-gallery-imgs'>
	           <volist name="object['gallery']" id="vo" key='i'>
		       <div class="wst-gallery-img">
			       <img class="gallery-img" width='140' height='100' iv="{$vo.goodsThumbs}" v="{$vo.goodsImg}" src="__ROOT__/{$vo.goodsThumbs}"/>
		       </div>
		       </volist>
	       </div>
	       <div style='clear:both;'></div>
	      </div>
       </div>
       </div>
       </form>

       <script type="text/javascript">
           (function($) {
               $.extend({
                   myTime: {
                       /**
                        * 当前时间戳
                        * @return <int>    unix时间戳(秒)
                        */
                       CurTime: function(){
                           return Date.parse(new Date())/1000;
                       },
                       /**
                        * 日期 转换为 Unix时间戳
                        * @param <string> 2014-01-01 20:20:20 日期格式
                        * @return <int>    unix时间戳(秒)
                        */
                       DateToUnix: function(string) {
                           var f = string.split(' ', 2);
                           var d = (f[0] ? f[0] : '').split('-', 3);
                           var t = (f[1] ? f[1] : '').split(':', 3);
                           return (new Date(
                                           parseInt(d[0], 10) || null,
                                           (parseInt(d[1], 10) || 1) - 1,
                                           parseInt(d[2], 10) || null,
                                           parseInt(t[0], 10) || null,
                                           parseInt(t[1], 10) || null,
                                           parseInt(t[2], 10) || null
                                   )).getTime() / 1000;
                       },
                       /**
                        * 时间戳转换日期
                        * @param <int> unixTime  待时间戳(秒)
                        * @param <bool> isFull  返回完整时间(Y-m-d 或者 Y-m-d H:i:s)
                        * @param <int> timeZone  时区
                        */
                       UnixToDate: function(unixTime, isFull, timeZone) {
                           if (typeof (timeZone) == 'number')
                           {
                               unixTime = parseInt(unixTime) + parseInt(timeZone) * 60 * 60;
                           }
                           var time = new Date(unixTime * 1000);
                           var ymdhis = "";
                           ymdhis += time.getUTCFullYear() + "-";
                           var M=(time.getUTCMonth()+1);
                           if(M.toString().length==1)M='0'+M;
                           ymdhis += M + "-";
                           var D=(time.getUTCDate());
                           if(D.toString().length==1)D='0'+D;
                           ymdhis += D;
                           if (isFull === true)
                           {
                               var H=(time.getUTCHours());
                               if(H.toString().length==1)H='0'+H;
                               ymdhis += ' '+H+':00:00';
                           }
                           return ymdhis;
                       }
                   }
               });
           })(jQuery);

           jeDate({
               dateCell:"#startTime",
               format:"YYYY-MM-DD hh:00:00",
               isinitVal:false,
               isTime:true, //isClear:false,
               minDate:"2014-09-19 00:00:00",
               choosefun:function(val) {
                   var house=val.split(':')[0].substr(-2,2);
                   if(house==00 || house==08 || house==12 || house==16 || house==20){
                       var temp=$.myTime.DateToUnix(val);
                       if(house==00){
                           temp=parseInt(temp+60*60*8);
                       }else{
                           temp=parseInt(temp+60*60*4);
                       }
                       temp=$.myTime.UnixToDate(temp,true,8);
                       $('#endTime').val(temp);
                   }else{
                       WST.msg('开始时间只能为：00:00,08:00,12:00,16:00,20:00!',{icon: 0});
                       $('#endTime').val('');
                       $('#startTime').val('');
                   }
               },  //选中日期后的回调
               clearfun:function(val) {$('#endTime').val('');},   //清除日期后的回调
               okfun:function(val){
                   var house=val.split(':')[0].substr(-2,2);
                   if(house==00 || house==08 || house==12 || house==16 || house==20){
                       var temp=$.myTime.DateToUnix(val);
                       if(house==00){
                           temp=parseInt(temp+60*60*8);
                       }else{
                           temp=parseInt(temp+60*60*4);
                       }
                       temp=$.myTime.UnixToDate(temp,true,8);
                       $('#endTime').val(temp);
                   }else{
                       WST.msg('开始时间只能为：00:00,08:00,12:00,16:00,20:00!',{icon: 0});
                       $('#endTime').val('');
                       $('#startTime').val('');
                   }
               }
           })
       </script>
   </body>
</html>